package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.OrderDete;
import com.indusfo.spc.service.OrderDeteService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/11/26 14:34
 * @Version 1.0
 */

@Controller
@RequestMapping("/service/orderDete")
public class OrderDeteController {

    @Autowired
    private OrderDeteService orderDeteService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryOrderDete")
    @ResponseBody
    public JSONObject queryOrderDete(OrderDete orderDete) {
        JSONObject json = orderDeteService.queryOrderDete(orderDete);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertOrderDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertOrderDete(OrderDete orderDete) {
        JSONObject json = orderDeteService.insertOrderDete(orderDete);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateOrderDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateOrderDete(OrderDete orderDete) {
        JSONObject json = orderDeteService.updateOrderDete(orderDete);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteOrderDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteOrderDete(@RequestParam("orderDeteIds") List<Integer> orderDeteIds, Integer dataState) {
        dataState = 2;
        JSONObject json = orderDeteService.deleteOrderDete(orderDeteIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedOrderDete", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedOrderDete(@RequestParam("orderDeteIds") List<Integer> orderDeteIds, Integer dataState) {
        JSONObject json = orderDeteService.deleteOrderDete(orderDeteIds, dataState);
        return json;
    }
}
